package com.jacken.mars.utils;

import lombok.extern.slf4j.Slf4j;
import mob.push.api.client.push.PushV3Client;
import mob.push.api.config.MobPushConfig;
import mob.push.api.exception.ApiException;
import mob.push.api.http.Result;
import mob.push.api.res.PushV3Res;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangqinag
 * @version 1.0
 * @date 2020/12/29 14:45
 */
@Slf4j
public class MobPushUtils {

    public static Object push1(String cmd, String custPhone) {
        MobPushConfig.appkey = "m31ecc22cb8df0";
        MobPushConfig.appSecret = "04fc3d674976e873e816d7c4aee6b7f3";
        List<String> list = new ArrayList<String>();
        list.add(custPhone);
        try {
            //Registration ID推送
            Result<PushV3Res> resResult = PushV3Client.pushByAlias("test1", "脸咔", cmd, custPhone);
            return resResult;
        } catch (ApiException e) {
            //错误请求状态码
            int status = e.getStatus();
            //错误状态码
            int errorCode = e.getErrorCode();
            //错误信息
            String errorMessage = e.getErrorMessage();
            log.error(String.valueOf(status));
            log.error(String.valueOf(errorCode));
            log.error(errorMessage);
        }
        return null;
    }

    public static void main(String[] args) {
        //调用方法
        push1("1", "15656565556");
    }
}
